<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <div class="counter"></div>
    <button class="incr">+1</button>
    <button class="decr">-1</button>
    <script>
        // 获取全部元素
        const counter = document.querySelector('.counter')
        const incr = document.querySelector('.incr')
        const decr = document.querySelector('.decr')

        // 定义变量
        let counterNum = 100;
        counter.innerHTML = counterNum
        
        // 监听按钮点击
        incr.addEventListener('click',() =>{
            counter.innerHTML++;
        })

        decr.addEventListener('click',() =>{
            counter.innerHTML--;
        })

    </script>
</body>
</html>
